<template>
  <div>
    <el-row>
      <el-col>
        <el-form :inline="true" :model="formInline">
          <el-form-item>
            <el-input size="mini" v-model="formInline.user" placeholder="请输入设备编号"></el-input>
          </el-form-item>
          <el-form-item>
            <el-input size="mini" v-model="formInline.user" placeholder="请输入设备名称"></el-input>
          </el-form-item>
          <el-form-item>
            <el-select clearable size="mini" v-model="formInline.region" placeholder="请选择状态">
              <el-option label="出借" value="shanghai"></el-option>
              <el-option label="正常" value="beijing"></el-option>
              <el-option label="损坏" value="beijing2"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" size="mini">查询</el-button>
          </el-form-item>
        </el-form>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="4">
        <el-tree accordion highlight-current :data="data" :props="defaultProps" @node-click="handleNodeClick"></el-tree>
      </el-col>
      <el-col :span="20">
        <el-table
                :data="tableData"
                size="mini"
                border
                style="width: 100%">
          <el-table-column
                  align="center"
                  type="selection"
                  width="55">
          </el-table-column>
          <el-table-column
                  align="center"
                  prop="user"
                  label="设备编号">
          </el-table-column>
          <el-table-column
                  align="center"
                  prop="email"
                  label="资产名称">
          </el-table-column>
          <el-table-column
                  align="center"
                  prop="address"
                  label="单价">
          </el-table-column>
          <el-table-column
                  align="center"
                  prop="status"
                  label="规格">
          </el-table-column>
          <el-table-column
                  align="center"
                  prop="status2"
                  label="型号">
          </el-table-column>
          <el-table-column
                  align="center"
                  prop="status2"
                  label="购置日期">
          </el-table-column>
          <el-table-column
                  align="center"
                  prop="status2"
                  label="生产单位">
          </el-table-column>
          <el-table-column
                  align="center"
                  prop="status2"
                  label="设备类型">
          </el-table-column>
          <el-table-column
                  align="center"
                  prop="createUser"
                  label="是否电脑">
          </el-table-column>
          <el-table-column
                  align="center"
                  prop="createUser"
                  label="完好状况">
          </el-table-column>
          <el-table-column
                  align="center"
                  prop="createUser"
                  label="管理状态">
          </el-table-column>
        </el-table>
        <el-pagination
                background
                layout="total, sizes, prev, pager, next, jumper"
                :page-size="pagination.pageSize"
                :total="pagination.total"
                :page-sizes="[10, 20, 30, 50, 100]"
        >
        </el-pagination>
      </el-col>
    </el-row>
  </div>
</template>

<script>
  export default {
    name: "borrowLog",
    data() {
      return{
        fileList: [{name: 'food.jpeg', url: 'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100'}, {name: 'food2.jpeg', url: 'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100'}],
        dialogImageUrl: '',
        dialogVisible: false,
        dialogFormVisible3: false,
        form: {},
        form3: {},
        dialogFormVisible: false,
        form2:{
          deviceName: [ {name: ''}, {num: 1212}]
        },
        formLabelWidth: '120px',
        dialogFormVisible2: false,
        formInline: {},
        data: [],
        defaultProps: {
          children: 'list',
          label: 'NAME'
        },
        tableData: [{
          user: 'A01',
          email: '545082052@qq.com',
          createUser: 'superAdmin',
          date: '2018-08-08',
          status: '启用',
          status2: "正常"
        }, {
          user: 'A02',
          email: '545082052@qq.com',
          createUser: 'superAdmin',
          date: '2018-08-08',
          status: '禁用',
          status2: '归档'
        }, {
          user: 'B01',
          email: '545082052@qq.com',
          createUser: 'superAdmin',
          date: '2018-08-08',
          status: '禁用',
          status2: "正常"
        }, {
          user: 'B02',
          email: '545082052@qq.com',
          createUser: 'superAdmin',
          date: '2018-08-08',
          status: '启用',
          status2: '归档'
        }],
        pagination: {
          pageSize: 10,
          total: 1,
          pageNo: 1
        },
      }
    },
    created() {
      this.getTreeData()
    },
    methods: {
      getTreeData() {
        this.$post('/public/findStructureByTestBase').then(res => {
          this.data = res.data.data;
        })
      },
      handleNodeClick(data, node) {
        console.log(data);
        let departmentId = '';
        let testBaseId = '';
        let testId = '';
        if(node.level === 1) {
          departmentId = data.ID;
        }
        if(node.level === 2) {
          testBaseId = data.ID;
        }
        if(node.level === 3) {
          testId = data.ID;
        }
        this.$post('/insrtument/findInstrument',{
          departmentId, testBaseId,testId,
          pageSize: this.pagination.pageSize,
          pageNo: 1
        }).then(res => {
          this.tableData = res.data.data.dataList;
          this.pagination.total = res.data.data.total;
        })
      }
    }
  }
</script>

<style scoped lang="scss">
  .search{
    margin-bottom: 10px;
  }
  /deep/.el-select{
    width: 100%;
  }
  .addDev {
    /deep/.el-form-item__content {
      display: flex;
    }
  }
  /deep/.el-divider{
    background: #409eff;
  }
  /deep/.el-divider__text{
    font-size: 18px;
    color: #409eff;
  }
  /deep/.el-date-editor.el-input, .el-date-editor.el-input__inner {
    width: 100%
  }
</style>
